package com.tzpay.tzpay.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.tzpay.tzpay.common.StaticVars;

/**
 * Created by chenfeiyue on 16/4/7.
 */
public class TzPayDBHelper extends SQLiteOpenHelper {
    public TzPayDBHelper(final Context context) {
        super(context, StaticVars.DB_NAME, null, StaticVars.VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        createMultiMediaInfoTable(db);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }

    @Override
    public void onOpen(SQLiteDatabase db) {
        super.onOpen(db);
    }

    /**
     * 订单信息表
     */
    private void createMultiMediaInfoTable(SQLiteDatabase db) {
        String sql = "CREATE TABLE IF NOT EXISTS "
                + StaticVars.Table.ORDER_INFO + " ( "
                + StaticVars.Column._ID + " INTEGER PRIMARY KEY autoincrement, "
                + StaticVars.Column.ORDER_NO + " VARCHAR , "
                + StaticVars.Column.ORDER_REQ_NO + " VARCHAR, "
                + StaticVars.Column.MERCHAT_ID + " VARCHAR, "
                + StaticVars.Column.SUB_MERCHAT_ID + " VARCHAR, "
                + StaticVars.Column.ORDER_DATE + " VARCHAR, "
                + StaticVars.Column.ORDER_AMT + " VARCHAR, "
                + StaticVars.Column.PRODUCT_AMT + " LONG, "
                + StaticVars.Column.ATTACH_AMT + " VARCHAR, "
                + StaticVars.Column.GOODS_NAME + " VARCHAR, "
                + StaticVars.Column.STORE_ID + " VARCHAR, "
                + StaticVars.Column.OUR_TRANS_NO + " VARCHAR, "
                + StaticVars.Column.ERROR_CODE + " VARCHAR, "
                + StaticVars.Column.ERROR_MSG + " VARCHAR, "
                + StaticVars.Column.REFUND_FLAG + " VARCHAR, "
                + StaticVars.Column.CUSTOMER_ID + " VARCHAR, "
                + StaticVars.Column.REFUND_REQ_NO + " VARCHAR, "
                + StaticVars.Column.REFUND_REQ_DATE + " VARCHAR, "
                + StaticVars.Column.TRANS_AMT + " VARCHAR, "
                + StaticVars.Column.TRANS_STATUS + " VARCHAR, "
                + StaticVars.Column.ENCODE_TYPE + " VARCHAR, "
                + StaticVars.Column.SIGN + " VARCHAR, "
                + StaticVars.Column.BARCODE + " VARCHAR, "
                + StaticVars.Column.CHANNEL + " VARCHAR, "
                + StaticVars.Column.BUSI_TYPE + " VARCHAR, "
                + StaticVars.Column.BACK_URL + " VARCHAR, "
                + StaticVars.Column.LEDGER_DETAIL + " VARCHAR, "
                + StaticVars.Column.TEMP_1 + " VARCHAR, "
                + StaticVars.Column.TEMP_2 + " VARCHAR, "
                + StaticVars.Column.TEMP_3 + " VARCHAR, "
                + StaticVars.Column.TEMP_4 + " VARCHAR, "
                + StaticVars.Column.TEMP_5 + " VARCHAR, "
                + StaticVars.Column.TEMP_6 + " VARCHAR, "
                + StaticVars.Column.TEMP_7 + " VARCHAR, "
                + StaticVars.Column.TEMP_8 + " VARCHAR, "
                + StaticVars.Column.TEMP_9 + " VARCHAR, "
                + StaticVars.Column.TEMP_10 + " VARCHAR, "
                + StaticVars.Column.UPLOAD_FLAG + " VARCHAR DEFAULT 'false'" + ")";
        db.execSQL(sql);
    }

}
